package com.ruoyi.project.tool.swagger.UserController;

import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.lang.UUID;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.aspectj.lang.annotation.Ide;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.annotation.SignatureValidation;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.aspectj.lang.enums.OperatorType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.system.domain.SysCompany;
import com.ruoyi.project.system.domain.SysReceive;
import com.ruoyi.project.system.service.ISysCompanyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.test.annotation.Repeat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 【请填写功能名称】Controller
 *
 * @author theme
 * @date 2020-05-27
 */
@Api(description = "查询活动配置")
@RestController
@RequestMapping("/mobileUser/company")
public class UserCompanyController extends BaseController {
    @Autowired
    private ISysCompanyService sysCompanyService;

    /**
     * 查询公司简介列表
     */
    @ApiOperation("查询活动配置")
    @GetMapping("/getDetail")
    @SignatureValidation
    @Ide
    public AjaxResult list(SysCompany sysCompany) {
        List<SysCompany> list = sysCompanyService.selectSysCompanyList(sysCompany);
        return AjaxResult.success(list.get(0));
    }

    /**
     * 查询公司简介列表
     */
    @ApiOperation("查询活动配置")
    @GetMapping("/getDetail/{id}")
    @SignatureValidation
    @Ide
    public AjaxResult list(@PathVariable("id" ) Long id) {
        SysCompany sysCompany = sysCompanyService.selectSysCompanyById(id);
        Long times=new Date().getTime();
        if(times<sysCompany.getStartTime().getTime()||times>sysCompany.getFinishTime().getTime()){
            return AjaxResult.error(HttpStatus.ACTIVITY,"未在活动时间范围内!");
        }
        return AjaxResult.success(sysCompany);
    }

    @PostMapping(value = "/validLogin")
    @Log(title = "校验客户验证码", operatorType = OperatorType.MOBILE)
    @SignatureValidation
    @ApiOperation("校验客户验证码")
    public AjaxResult codeLogin(@RequestBody Map map) {
        if (null == map.get("type")) {
            return AjaxResult.error("业务类型为空");
        }
        return AjaxResult.success("操作成功", UUID.randomUUID().toString());
    }
}
